module.exports = function(grunt){
    grunt.initConfig({
	pkg: grunt.file.readJSON('package.json'),
    browserify: {
        main:{
			src:  'src/main/resources/static/app/**/*.js',
			dest: 'src/main/resources/static/dist/app/js/app.js'
        },
    },
	uglify: {
		main: {
			files: {
				'src/main/resources/static/dist/app/js/<%= pkg.name %>.min.js': ['<%= browserify.main.dest %>']
			}
		}
	},
    copy:{
//    	all:{
//			expand: true,
//			cwd: 'src/main/resources/static/src',
//			src: ['**/*.html','**/*css', '**/*.png'],
//			dest: 'src/main/resources/static/dist'
//        },
        angular:{
        	expand: true,
			cwd: 'node_modules/angular/',
			src: ['angular.min.js','angular.min.js.map'],
			dest: 'src/main/resources/static/dist/app/js/'
        }
    },
    karma: {
 		unit: {
   			configFile: 'karma.conf.js',
    		autoWatch: true
  		}
	},
	watch: {
		options:{
			livereload:true
        },
		main:{
			files:['src/main/resources/static/app/**/*.js'],
			tasks:['browserify:main','uglify:main']
		},
		html:{
			files:['**/*.html'],
			tasks:['copy:all']
		}
    }
    });
    

    grunt.loadNpmTasks('grunt-browserify');
    grunt.loadNpmTasks('grunt-contrib-copy');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-watch');
	
    grunt.registerTask('default',['browserify', 'copy']);
	grunt.registerTask('release',['browserify', 'uglify', 'copy']);
}